#pragma once
#ifndef MAP_H
#define MAP_H

#include "common_include.h"
#include "frame.h"
#include"landmark.h"

namespace test_visual_odom{

class Map {
    public:
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
    typedef shared_ptr<Map> Ptr;
    typedef unordered_map<unsigned long, Frame::Ptr> KeyFramesType;
    typedef unordered_map<unsigned long, LandMark::Ptr> LandmarksType;

    Map(){}

    void insertKeyFrame(Frame::Ptr p_frame);
    void insertLandMark(LandMark::Ptr landmark);

    LandmarksType getAllLandmarks(){  //landmark插入和访问是在一个线程，可以不用 锁
        // unique_lock<mutex> lck(data_mutex_);
        return landmarks_;
    }

    private:
    KeyFramesType keyframes_, active_keyframes_;
    LandmarksType landmarks_,active_landmarks_;        

    Frame::Ptr p_current_frame_ = nullptr;  //由于插入关键帧不一定都是新帧，因此，索引关键帧vector的话，不一定能找到 

    int num_active_keyframes_=7;

    // mutex data_mutex_;

    //移除旧的关键帧，滑动窗口，但是，还是需要边缘化，不然，会少一个约束
    void removeNotGoodKeyframe();
    void removeLandMarkNotObserved() ;
};


}
#endif
